<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-collapse [lvMultiExpansion]="'false'" lvType="simple">
    <lv-collapse-panel [lvTitle]="titleTpl" [lvExpanded]="false">
        <lv-form [formGroup]="formGroup" [lvLabelColon]="false" class="formGroup">
            <lv-form-item>
                <lv-form-label>
                    {{'protection_same_snapshot_label' | i18n}}
                    <i lv-icon="aui-icon-help"
                        lv-tooltip="{{(isFusionOne ? 'protection_fo_consistency_snapshot_help_label' : 'protection_fc_consistency_snapshot_help_label') | i18n}}"
                         class="configform-constraint" lvColorState='true'></i>
                </lv-form-label>
                <lv-form-control>
                    <lv-switch formControlName="isConsistent" [lvDisabled]='!isSupport'></lv-switch>
                    <div *ngIf="formGroup.value.isConsistent">
                        <i lv-icon="lv-icon-status-warning-info" lvColorState='true' class="type-icon"></i>
                        <span>
                            {{'protection_fc_consistency_snapshot_open_label' | i18n}}
                        </span>
                    </div>
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>
                    {{'protection_fc_snap_delete_speed_label' | i18n}}
                    <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_fc_snap_delete_speed_help_label' | i18n}}"
                        lvTooltipPosition="rightTop"  lvColorState='true'></i>
                </lv-form-label>
                <lv-form-control [lvErrorTip]="speedErrorTip">
                    <input formControlName="snapDeleteSpeed" lv-input />
                </lv-form-control>
            </lv-form-item>
            <lv-form-item>
                <lv-form-label>
                    {{'protection_clients_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    <lv-select [lvOptions]="hostOptions" formControlName="proxyHost" lvValueKey='value' lvShowFilter
                        lvShowCheckAll lvFilterKey='label' lvFilterMode='contains' lvMode="multiple"
                        [lvContentTemplate]="contentTpl"
                        lvPlaceholder="{{'protection_agent_placeholder_label' | i18n}}">
                    </lv-select>
                    <ng-template #contentTpl let-item>
                        <lv-group lvGutter="4px">
                            <i lv-icon="{{
                                  item.linkStatus === dataMap.resource_LinkStatus_Special.normal.value ? 'aui-host-online' : 'aui-host-offline'
                                }}"></i>
                            <span>{{ item.label }}</span>
                        </lv-group>
                    </ng-template>
                </lv-form-control>
            </lv-form-item>
            <aui-update-index [formGroup]="formGroup" [extParams]="extParams" [noNeedMgt]="!includes([
            dataMap.Resource_Type.fusionComputeVirtualMachine.value,
            dataMap.Resource_Type.vmGroup.value
            ],resourceType)"></aui-update-index>
            <ng-container *ngIf="!includes([
                dataMap.Resource_Type.fusionComputeVirtualMachine.value,
                dataMap.Resource_Type.vmGroup.value
            ],resourceType)
             ">
                <lv-form-item>
                    <lv-form-label>
                        {{'protection_overwrite_policy_label' | i18n}}
                        <i lv-icon="aui-icon-help" [lv-tooltip]="slaOverwriteHelp" lvTooltipPosition="rightTop"
                             class="configform-constraint" lvColorState='true'></i>
                    </lv-form-label>
                    <lv-form-control>
                        <lv-radio-group formControlName="slaOverwrite">
                            <lv-group [lvGutter]="'8px'" lvDirection='vertical' class="mgt-8">
                                <lv-radio [lvValue]="false" [lvDisabled]="resourceData.ext_parameters">
                                    {{ (resourceType === ResourceType.HOST ? 'protection_not_overwrite_sla_label' :
                                    'protection_not_overwrite_host_sla_label') | i18n }}
                                </lv-radio>
                                <lv-radio [lvValue]="true" [lvDisabled]="resourceData.ext_parameters">
                                    {{ (resourceType === ResourceType.HOST ? 'protection_overwrite_sla_label' :
                                    'protection_overwrite_host_sla_label') | i18n }}
                                </lv-radio>
                            </lv-group>
                        </lv-radio-group>
                    </lv-form-control>
                </lv-form-item>
                <lv-form-item>
                    <lv-form-label>
                        {{'protection_apply_policy_label' | i18n}}
                    </lv-form-label>
                    <lv-form-control>
                        <lv-checkbox-group formControlName="slaPolicy" [lvDisabled]="disabled">
                            <lv-group [lvGutter]="'8px'" lvDirection='vertical' class="mgt-8">
                                <lv-checkbox lvValue="APPLY_TO_ALL">
                                    {{ (resourceType === ResourceType.HOST ? 'protection_apply_sla_in_cna_vmware_label'
                                    : 'protection_apply_sla_in_cluster_vmware_label') | i18n }}
                                    <i lv-icon="aui-icon-help" [lv-tooltip]="slaApplyAllHelp"
                                        lvTooltipPosition="rightTop"  lvColorState='true'></i>
                                </lv-checkbox>
                                <lv-checkbox lvValue="APPLY_TO_NEW">
                                    {{ (resourceType === ResourceType.HOST ?
                                    'protection_apply_sla_in_no_cna_vmware_label' :
                                    'protection_apply_sla_in_no_cluster_vmware_label') | i18n }}
                                </lv-checkbox>
                            </lv-group>
                        </lv-checkbox-group>
                    </lv-form-control>
                </lv-form-item>
                <aui-protect-filter [formGroup]="formGroup" [valid$]="valid$" [resType]="resourceType">
                </aui-protect-filter>
            </ng-container>
        </lv-form>
        <!-- 防勒索副本设置参数 -->
        <ng-container *ngIf="includes([
                dataMap.Resource_Type.fusionComputeVirtualMachine.value,
                dataMap.Resource_Type.vmGroup.value
            ],resourceType)">
            <aui-copy-limit-advanced-parameter [formGroup]="formGroup"
                [data]="resourceData"></aui-copy-limit-advanced-parameter>
        </ng-container>
    </lv-collapse-panel>
</lv-collapse>

<ng-template #titleTpl>
    <lv-group lvGutter='8px'>
        <span class="aui-h3">{{'common_advanced_label'|i18n}}</span>
    </lv-group>
</ng-template>
